Class MigrationRunner

Summary

Fully Qualified Name: CodeIgniter\Database\MigrationRunner

Description

Class MigrationRunner

Methods

Name Description Defined By
__construct() Constructor. MigrationRunner
clearCliMessages() Clears any CLI messages. MigrationRunner
clearHistory() Truncates the history table. MigrationRunner
ensureTable() Ensures that we have created our migrations table in the database. MigrationRunner
findMigrations() Retrieves list of available migration scripts MigrationRunner
findNamespaceMigrations() Retrieves a list of available migration scripts for one namespace MigrationRunner
force() Migrate a single file regardless of order or batches. MigrationRunner
getBatchEnd() Returns the version number of the last migration for a batch. MigrationRunner
getBatchHistory() Returns the migration history for a single batch. MigrationRunner
getBatchStart() Returns the version number of the first migration for a batch. MigrationRunner
getBatches() Returns all the batches from the database history in order MigrationRunner
getCliMessages() Retrieves messages formatted for CLI output MigrationRunner
getHistory() Grabs the full migration history from the database for a group MigrationRunner
getLastBatch() Returns the value of the last batch in the database. MigrationRunner
getObjectUid() Uses the non-repeatable portions of a migration or history to create a sortable unique key MigrationRunner
latest() Locate and run all new migrations MigrationRunner
regress() Migrate down to a previous batch MigrationRunner
setGroup() Set database Group. MigrationRunner
setName() Set migration Name. MigrationRunner
setNamespace() Set namespace. MigrationRunner
setSilent() If $silent == true, then will not throw exceptions and will attempt to continue gracefully. MigrationRunner

Method Details

__construct()

Constructor.

When passing in $db, you may pass any of the following to connect:

Parameter Name Type Description
$config \BaseConfig
$db \CodeIgniter\Database\ConnectionInterface|array|string

Returns:

clearCliMessages()

Clears any CLI messages.

Returns: \MigrationRunner

clearHistory()

Truncates the history table.

Returns: bool

ensureTable()

Ensures that we have created our migrations table in the database.

Returns:

findMigrations()

Retrieves list of available migration scripts

Returns: array List of all located migrations by their UID

findNamespaceMigrations()

Retrieves a list of available migration scripts for one namespace

Parameter Name Type Description
$namespace string The

Returns: array List of unsorted migrations from the namespace

force()

Migrate a single file regardless of order or batches.

Method "up" or "down" determined by presence in history. NOTE: This is not recommended and provided mostly for testing.

Parameter Name Type Description
$path string Namespace
$group string|null
$namespace

Returns:

getBatchEnd()

Returns the version number of the last migration for a batch.

Mostly just for tests.

Parameter Name Type Description
$batch int

Returns: string

getBatchHistory()

Returns the migration history for a single batch.

Parameter Name Type Description
$batch int
$order

Returns: array

getBatchStart()

Returns the version number of the first migration for a batch.

Mostly just for tests.

Parameter Name Type Description
$batch int

Returns: string

getBatches()

Returns all the batches from the database history in order

Returns: array

getCliMessages()

Retrieves messages formatted for CLI output

Returns: array Current migration version

getHistory()

Grabs the full migration history from the database for a group

Parameter Name Type Description
$group string

Returns: array

getLastBatch()

Returns the value of the last batch in the database.

Returns: int

getObjectUid()

Uses the non-repeatable portions of a migration or history to create a sortable unique key

Parameter Name Type Description
$migration object or
$object

Returns: string

latest()

Locate and run all new migrations

Parameter Name Type Description
$group string|null

Returns:

regress()

Migrate down to a previous batch

Calls each migration step required to get to the provided batch

Parameter Name Type Description
$targetBatch int Target
$group string|null

Returns: mixed Current batch number on success, FALSE on failure or no migrations are found

setGroup()

Set database Group.

Allows other scripts to modify on the fly as needed.

Parameter Name Type Description
$group string

Returns: \MigrationRunner

setName()

Set migration Name.

Parameter Name Type Description
$name string

Returns: \CodeIgniter\Database\MigrationRunner

setNamespace()

Set namespace.

Allows other scripts to modify on the fly as needed.

Parameter Name Type Description
$namespace string or

Returns: \MigrationRunner

setSilent()

If $silent == true, then will not throw exceptions and will attempt to continue gracefully.

Parameter Name Type Description
$silent bool

Returns: \MigrationRunner

Top